describe('Useful Ember.js Functions', function() {
	/**
	 * http://code418.com/blog/2012/03/08/useful-emberjs-functions/
	 * Others:
	 * Ember.LOG_BINDINGS = true;
	 * Em.K // a function return this
	 * Em.inspect() // returns a string description of a given object
	 */


    it('Object: create | extend | reopon ', function() {
		
        var a = Ember.Object.create({
            one: function() {
                console.log('one');
                return 'one';
            },
            two: function() {
                console.log('two');
                return 'two';
            },
            three: 'three'            
        });

        expect(a.one()).toBe('one');

    });



    it('none', function() {
        expect(Ember.isNone()).toBeTruthy();
        expect(Ember.isNone(null)).toBeTruthy();
        expect(Ember.isNone(undefined)).toBeTruthy();
        expect(Ember.isNone('')).toBeFalsy();
        expect(Ember.isNone([])).toBeFalsy();
        expect(Ember.isNone(function(){})).toBeFalsy();
    });

    it('empty', function() {
        expect(Ember.isEmpty()).toBeTruthy();
        expect(Ember.isEmpty(null)).toBeTruthy();
        expect(Ember.isEmpty(undefined)).toBeTruthy();
        expect(Ember.isEmpty('')).toBeTruthy();
        expect(Ember.isEmpty([])).toBeTruthy();
        expect(Ember.isEmpty('abc')).toBeFalsy();
        expect(Ember.isEmpty([0, 1, 2])).toBeFalsy();
    });

    it('isArray', function() {
        expect(Ember.isArray()).toBeFalsy();
        expect(Ember.isArray([])).toBeTruthy();
        expect(Ember.isArray(Ember.ArrayProxy.create({ content: [] }))).toBeTruthy();
    });

    it('makeArray', function() {
        expect(Ember.makeArray()).toEqual([]);
        expect(Ember.makeArray(null)).toEqual([]);
        expect(Ember.makeArray(undefined)).toEqual([]);
        expect(Ember.makeArray('abc')).toEqual(['abc']);
        expect(Ember.makeArray([1, 2, 3])).toEqual([1, 2, 3]);

        var controller = Ember.ArrayProxy.create({ content: [] });
        expect(Ember.makeArray(controller)).toEqual(controller);
    });

    it('typeOf', function() {
        expect(Ember.typeOf()).toEqual('undefined');
        expect(Ember.typeOf(null)).toEqual('null');
        expect(Ember.typeOf(undefined)).toEqual('undefined');
        expect(Ember.typeOf('abc')).toEqual('string');
        expect(Ember.typeOf(123)).toEqual('number');
        expect(Ember.typeOf(true)).toEqual('boolean');
        expect(Ember.typeOf(Ember.makeArray)).toEqual('function');
        expect(Ember.typeOf([1,2,3])).toEqual('array');
        expect(Ember.typeOf(Ember.Object.extend())).toEqual('class');
        expect(Ember.typeOf(Ember.Object.create())).toEqual('instance');
        expect(Ember.typeOf(new Error('teamocil'))).toEqual('error');
        expect(Ember.typeOf({a: 'b'})).toEqual('object');
    });

    it('compare', function() {
        expect(Ember.compare('hello', 'hello')).toEqual(0);
        expect(Ember.compare('abc', 'dfg')).toEqual(-1);
        expect(Ember.compare(2, 1)).toEqual(1);
    });

    it('isEqual', function() {
        expect(Ember.isEqual('hello', 'hello')).toBeTruthy();
        expect(Ember.isEqual(2, 1)).toBeFalsy();
        expect(Ember.isEqual([4,2], [4,2])).toBeFalsy();
    });

    it('copy', function() {
        expect(Ember.copy('hello')).toEqual('hello');
    });

    it('w()', function() {
        expect('thanks  brother!'.w()).toEqual(['thanks', 'brother!']);
        expect(''.w()).toEqual(['']);
    });

    it('fmt', function() {
        expect('Full name: %@ %@'.fmt('Michael', 'Bluth')).toEqual('Full name: Michael Bluth');
        expect('%@3 %@1 %@2'.fmt('my', 'world', 'Hello')).toEqual('Hello my world');
    });

    it('loc', function() {
		Ember.STRINGS = {
		    '_greeting': 'Hello %@',
		    '_page X of Y': 'page %@ of %@'
		};

        expect('_greeting'.loc('GOB')).toEqual('Hello GOB');
        expect('_page X of Y'.loc(2,129)).toEqual('page 2 of 129');
        expect('_Not found'.loc()).toEqual('_Not found');
    });



});